﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using log4net.Config;

namespace LAPI.Core.Logging
{
    public class LoggerFactory 
    {
        public static String ConfigFile { get; set; }

        public static ILogger CreateLogger(Type type)
        {
            ConfigureLogger(configFile: ConfigFile);

            return new DefaultLogger(log4net.LogManager.GetLogger(type));
        }

        public static ILogger CreateLogger(String name)
        {
            ConfigureLogger(configFile: ConfigFile);

            return new DefaultLogger(log4net.LogManager.GetLogger(name));
        }

        protected static void ConfigureLogger(String configFile)
        {
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(configFile));
        }
    }
}
